hello world and Programming to QSPI Flash for Operation

Introduction

Creating the Hardware Project in Vivado

Creating a New Vivado Project

VeryCapture_20250604115611

VeryCapture_20250604115813

VeryCapture_20250618094011

VeryCapture_20250604121357

VeryCapture_20250604122008

VeryCapture_20250618095743

VeryCapture_20250618095822

Creating the Processing System in Block Design

VeryCapture_20250618100007

VeryCapture_20250604135328

VeryCapture_20250604135703

VeryCapture_20250604135821

VeryCapture_20250604135937

Zynq Block Design: Shows various configurable blocks of the Zynq processing system (PS), where the gray parts are unmodifiable, and the green highlighted parts are configurable. There are two ways to enter the configuration page: directly click on various configurable blocks (green highlighted parts) to enter their configuration page for configuration, or select the page navigation on the left to enter the corresponding page for configuration. PS-PL Configuration: Configure the PS-PL interface, including AXI GP, HP and other bus interfaces. Peripheral I/O Pins: Select MIO/EMIO for different I/O peripherals. MIO Configuration: Specifically configure MIO/EMIO for different I/O peripherals. Clock Configuration: Used to configure the PS input clock, peripheral clock, as well as DDR and CPU clocks, etc. DDR Configuration: Used to set DDR controller configuration information. SMC Timing Calculation: Used to perform SMC timing calculations. Interrupts: Used to configure PS-PL interrupt ports.

image-20250621125144559

VeryCapture_20250604143436

 

MIO14 and MIO15 in BANK500 are used as pins for UART serial communication and are ultimately connected to the USB-to-serial chip CH340X on the baseboard. Therefore, to achieve serial communication functionality, we need to configure MIO14 and MIO15 as interface pins for the UART0 module in the PS.

VeryCapture_20250604150543

VeryCapture_20250604150502

Click the MIO Configuration page on the left, expand I/O Peripherals > UART0 on the right, and you can see its specific pin configuration information: MIO14 as the RX pin, MIO15 as the TX pin.

VeryCapture_20250604151515

VeryCapture_20250604151755

VeryCapture_20250604152226

image-20250621130649186

VeryCapture_20250604153711

VeryCapture_20250604153852

VeryCapture_20250604154146

VeryCapture_20250604154323

VeryCapture_20250604154550

In this interface, we can choose to automatically connect the interfaces of the IP module. This project has only one IP module. Confirm to check processing_system7_0 on the left, then click "OK". At this point, the ZYNQ7 PS module has引出 two groups of external interfaces, namely DDR and FIXED_IO. The引出 interfaces will be assigned to specific pins of the ZYNQ device. By clicking the "+" at the interface of the ZYNQ7 PS module to expand these two groups of interfaces, you can observe which signals each contains.

VeryCapture_20250604154645

VeryCapture_20250604154855

Generating the HDL Top-Level File

VeryCapture_20250604155500

VeryCapture_20250604160224

VeryCapture_20250604160348

VeryCapture_20250604160822

VeryCapture_20250604160857

VeryCapture_20250604161255

Generating the Bitstream File and Exporting the xsa File

If PL resources are used in the design, pin constraints need to be added, and the design needs to be synthesized, implemented, and a Bitstream file generated. Since this project is a minimum system and does not use the PL part, these steps are not necessary, and the hardware can be directly exported to xsa.

VeryCapture_20250604162230

In the popped-up interface, click next directly:

VeryCapture_20250604162321

Since we have not generated a bitstream file, directly select the first option in the next interface. If a bitstream file has been generated, click the second option "Include bitstream", click next:

VeryCapture_20250604162618

Next, a .xsa file will be generated. This file packages all hardware components and hardware platform information. The .xsa file will be used later with Vitis software or Linux.

VeryCapture_20250618102749

Finally, click finish to complete:

VeryCapture_20250618102827

VeryCapture_20250604164546

Creating the Software Project in Vitis

platform project and application project

In vitis, two types of projects can be created: platform project and application project.

Comparison ItemPlatform ProjectApplication Project
PurposeDefine hardware infrastructureDevelop software running on hardware
Input DependencyVivado exported .xsa fileExisting platform (.xpfm or directly .xsa)
Modification FrequencyLow frequency (rarely changed after hardware is stable)High frequency (code iterative development)
Output File.xpfm (platform description file).elf (executable file)
Typical UserHardware engineer/System architectSoftware engineer/Embedded developer

When creating a vitis project, you can first create a platform project, and then create an application project based on that platform project. You can also directly create an application project, but this will automatically create a platform project associated with that application project.

Here, taking creating the platform project first and then the application project as an example, let's talk about the creation process.

Creating the platform project

Subsequently, our application projects will be based on the created platform project.

image-20250621141749253

VeryCapture_20250618104211

Click "Browse", select the xsa file generated by vivado.

VeryCapture_20250605134327

After selection, the operating system used will automatically pop up in the options below. Also check "Generate boot components", which will automatically add fsbl-related files to the hardware platform. Click "Finish":

image-20250623102451632

At this point, the platform project creation is completed. Subsequent application projects we create will be based on this platform project. As shown:

image-20250623102742671

If the hardware resource file (.xsa) is modified later (by recompiling in vivado to generate a new xsa file), just update the hardware resource file. The specific operation is to right-click on the platform project, select "update Hardware specification" from the popped-up options. In the popped-up window, select the newly generated xsa file. Then right-click on this platform project and select Build project to rebuild the platform project.

image-20250621144532679

Next, we need to create an application project based on this platform project.

Creating the Application Project

Create via File->New->Application Project:

image-20250621143033176

In the popped-up interface, click next:

VeryCapture_20250604171626

Select the previously created platform project:

Note here. If a platform project has not been created before, you can choose the Create a new platform from hardware tab. This will create the application project while also creating the platform project.

image-20250623103225954

Fill in the project name, click next:

image-20250623103555160

On the next page, you can choose the desired operating system. This time we use bare metal, click next:

VeryCapture_20250604172551

Select "Hello World" in "Templates": Since a simple "Hello World" project is being created, there is already generated code in the template, which can be used without modification. Click "Finish":

VeryCapture_20250604173209

At this point, the new application project is created, as shown:

image-20250623104640363

Click "hello_world_system"->"hello_world"->src, inside is the software .c file:

image-20250623104611615

Compilation

Right-click "hello_world", click "build project" to compile the code. If there are no errors, an elf file will be generated. If there are errors, error prompts will be seen in the Problems page.

image-20250623104856653

Debugging

Configure the boot mode DIP switch of the development board to JTAG mode. Use a type-C USB cable to connect the JTAG port on the development board to the computer. The development board power is already on. Prepare another type-C USB cable to connect the PS_UART port on the development board to the computer. At the same time, open a serial port tool (such as MobaXterm) on the computer, select the corresponding recognized USB serial port, and set its baud rate to 115200.

image-20250808124540635

Click "Xilinx"->"XSCT Console", the XSCT console will appear in the lower right corner. Enter the "connect" command. This command establishes a debugging connection with the target hardware (such as our Zynq-7020 development board). Then enter the "targets" command. This command lists all available debugging targets (processors/hardware components) in the current system. If the response shown in the figure appears, it means the connection is successfully established.

VeryCapture_20250605110600

You can right-click and select Debug as:

image-20250623104955459

Or operate via the Debug shortcut: Click the drop-down to pop up the drop-down options, and select the application project that needs debugging:

image-20250623105305485

At this point, it will enter debug mode. By default, it jumps directly to main(). After that, you can perform step-by-step debugging, breakpoint debugging:

image-20250623105736534

If you need to reload the program, you can right-click on Debug->[System Project Debug], select terminate and relaunch:

image-20250623105935540

After Run, the "Hello World" and other character information will be printed on the computer's serial port tool.

Generating BOOT.bin

There are two ways to generate BOOT.bin:

Directly Generated via "Build Project"

Right-click on "hello_world_system" and build project. This will automatically first compile "hello_world" to generate the elf file, then merge the generated elf file with the fsbl.elf file and bitstream file from the platform project to generate the BOOT.bin file. Ultimately, it is this BOOT.bin file that is programmed into the flash.

image-20250623110335962

image-20250623110634193

Manually Generating BOOT.BIN

Right-click "hello_world_system", click "Create Boot Image". Or operate via the menu Xilinx->Create Boot Image.

image-20250623110853134

Select "Create new BIF file", must ensure the "Output format" type is BIN, as shown below:

image-20250623111229773

Add the following content in order:

Finally, click "Create Image" to complete the creation.

image-20250623111719181

image-20250623111849955

image-20250623112404183

If the result shown in the figure appears, it indicates successful creation.

image-20250623112104336

When manually generating the BOOT.bin file later, you can click "Import form existing BIF file", select the correct file path, and click "Create Image ":

image-20250623112540555

Programming to QSPI-Flash

Click "Xilinx"->"Program Flash":

VeryCapture_20250605110823

In the appeared interface, must ensure that the "Image File" is the generated BOOT.BIN file, the "Offset" starts from 0x00000000, and the "Init File" is the "fsbl.elf" file.

Explain the roles of the BOOT.Bin and fsbl.elf files:

BOOT.BIN:

fsbl.elf:

image-20250623112728041

Click "Program" and wait a few seconds. If "Flash Operation Successful" appears, it indicates successful programming of the QSPI Flash.

VeryCapture_20250605111329

Power off the development board, set the DIP switch corresponding to the boot mode to QSPI boot mode. Connect the PS_UART serial port to the computer via a type-C cable, and power on. Open the corresponding serial port on the computer using a serial port tool. Then press the reset button on the development board, and you can see the corresponding output information on the computer's serial port tool.